<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>第二题</title>
</head>
<body>
<pre>
from functools import wraps

class AuthClass:
 def __init__(self, name, pwd):
  self.name = name
  self.pwd = pwd
 def auth(self):
  if self.name == "python" and self.pwd == "123":
   return True
  else:
   return False

user = AuthClass("python", "123")

def auth_before(f):
 @wraps(f)
 def inner(*args, **kwargs):
   if not user.auth():
     print("⽤户名或密码错误")
     return False
   else:
     return f(*args, **kwargs)
 return inner

@auth_before
def p1():
 return "this is p1 function"

print(p1())
</pre>
</body>
</html>